<?php
/*
	地区代理管理
*/
defined('BY_JYA') or exit('error');
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','query'=>'status=1','title'=>'已审核'),
	array('op'=>'list','query'=>'status=0','title'=>'待审核'),
	array('op'=>'list','query'=>'status=2','title'=>'被拒绝'),
);
$return['statuss']=array(
		'0'=>'待审核',
		'1'=>'审核通过',
		'2'=>'审核不通过',
);
$return['stops']=array(
		'0'=>'正常',
		'1'=>'禁用',
);
$return['types']=$this->agent_types();
if($_RQ['op']=='list'){
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	
	$params['mid']=$_SESSION['uid'];
	$params['type >']=0;
	if(isset($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 100;
	$total='';
	$fields=array();
	$list=pdo_getslice('jy_move_agentcar_agent',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			
			$item['agent_area']=pdo_getcolumn('core_area',array('code'=>$item['area_code']),'address');
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			
			array('name'=>'type','title'=>'类型','type'=>'radio','options'=>'types'),
			array('name'=>'agent_area','title'=>'代理地区','type'=>'string'),
			array('name'=>'status','title'=>'审核状态','type'=>'radio','options'=>'statuss'),
			array('name'=>'stop','title'=>'是否禁止','type'=>'radio','options'=>'stops'),
			array('name'=>'createtime','title'=>'成为代理商时间','type'=>'time'),
		)),
		
	);
	if($_SESSION['os']=='windows'){
		$return['htmls']=$htmls;
	}
	set_html('tabs',$tabs);
	exi($return);
}
